package com.scau.dunka.service;

import com.easyFramework.annotation.Service;
import com.scau.dunka.bean.User;
import com.scau.dunka.dao.UserDao;
import com.scau.dunka.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

/**
 *  Dunka 19-1-10
 *  用处：管理员登录检验
 */
@Service
public class UserService {
    private UserDao userDao;
    public boolean login(String username,String password){

        SqlSession session = MybatisUtil.openSession();
        UserDao userDao = session.getMapper(UserDao.class);
        User user = userDao.getUser(username,password);
        if(user==null){
            if(session!=null)
                session.close();
            return  false;
        }else{
            if (session!=null)
                session.close();
            return true;
        }

    }
}
